var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var UI_Hall_UIBindings = require("AA_UI_Hall_UIBindings");
var BundleConfig = require("AA_BundleConfig");
var UIManager = require("AA_UIManager");
var UIView = require("AA_UIView");
var UIConfig_Home = require("AA_UIConfig_Home");
var EventManager = require("AA_EventManager");
var EvenType = require("AA_EvenType");
var AudioManager = require("AA_AudioManager");
var UIConfig_Game = require("AA_UIConfig_Game");
var PlayerDataManager = require("AA_PlayerDataManager");
var ModuleManager = require("AA_ModuleManager");
var BaseModule = require("AA_BaseModule");
var GameGlobalVariable = require("AA_GameGlobalVariable");
var Const_Common = require("AA_Const_Common");
var GuideControl = require("AA_GuideControl");
var HallGlobalVariable = require("AA_HallGlobalVariable");
var AIControl = require("AA_AIControl");
var RedPointControl = require("AA_RedPointControl");
var GameDataManager = require("AA_GameDataManager");
var TipsManager = require("AA_TipsManager");
var ResLoader = require("AA_ResLoader");
var HallManager = require("AA_HallManager");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_Hall = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.auto_ui = null;
    t._dt = 0;
    return t;
  }
  var _ref__creator;
  __extends(_creator, e);
  _ref__creator = _creator;
  _creator.prototype._show = function () {
    var e = this;
    _ref__creator._instance = this;
    EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Load_View, false);
    this.auto_ui.node_setting.active = false;
    this.auto_ui.setClickFast(this.auto_ui.btn_setting);
    this.auto_ui.btn_sidebar.node.active = false;
    cc.sys.platform == cc.sys.BYTEDANCE_GAME && mg.checkScene({
      scene: "sidebar",
      success: function (t) {
        e.auto_ui.btn_sidebar.node.active = t.isExist;
      }
    });
    AudioManager.AudioMgr.playMusic("home/sound/homebg", true, BundleConfig.BundleNames.Home);
    this.ResetRichLabel();
    PlayerDataManager.PlayerDataMgr.getWuJinCount();
    HallGlobalVariable.default.selfMap["战斗按钮"] = this.auto_ui.btn_fightingBtn.node;
    this.scheduleOnce(function () {
      e.ifJiXuGame();
    });
    GameGlobalVariable.GameGlobalVariable.openName("Hall");
    this.CheckUnLockFurit();
    this.loadGame();
  };
  _creator.prototype.CheckUnLockFurit = function () {
    var e = this;
    if ("Game" == GameGlobalVariable.GameGlobalVariable.getEndName()) {
      var t = this;
      var o = PlayerDataManager.PlayerDataMgr.dressUpArray.filter(function (e) {
        return -1 == e;
      });
      var n = PlayerDataManager.PlayerDataMgr.GameWinCheckUnlock();
      var i = PlayerDataManager.PlayerDataMgr.dressUpArray.filter(function (e) {
        return -1 == e;
      });
      i && o && i.length < o.length && n && n.unshift(HallGlobalVariable.default.shangZhenId);
      HallManager.HallMgr.wuYongMap.isUnLockWuJin || GameDataManager.GameDataMgr.getNowMaxLevel() >= GameGlobalVariable.GameGlobalVariable.wujinunlockcount && (n.unshift(HallGlobalVariable.default.wuJinId), HallManager.HallMgr.wuYongMap.isUnLockWuJin = true, HallManager.HallMgr.SaveWuYongMap());
      if (n && n.length > 0) {
        UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_UnlockNewEquip, {
          shuiGuoIds: n,
          callBack: function () {
            if (PlayerDataManager.PlayerDataMgr.GetGuideIndexByTaskName(Const_Common.GuideName.水果上阵) == Const_Common.DressUpEquipGuideIndex.引导对话) {
              var o = t.auto_ui.btn_wareHouseBtn.node;
              var n = o.convertToWorldSpaceAR(cc.v2(0, 0));
              var i = cc.size(o.width, o.height);
              var a = (e.node.height - 1334) / 2;
              GuideControl.GuideCtrl.ShowGuide({
                callBack: function () {
                  PlayerDataManager.PlayerDataMgr.SetGuideIndex(Const_Common.GuideName.水果上阵, Const_Common.DressUpEquipGuideIndex.选择水果);
                  t.ShowViewByType(1);
                },
                sayStr: "恭喜解锁了新水果，赶紧去将新水果上阵吧",
                wPos: n,
                size: i,
                sayNodePos: cc.v2(0, -250 - a)
              });
            } else {
              AIControl.default._instance.ShowClickBtn(t.auto_ui.btn_wareHouseBtn.node, function () {
                t.ShowViewByType(1);
              });
            }
            EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.HallResetBag);
            HallGlobalVariable.default.isNeedResetWareHouse = true;
          }
        });
      } else {
        RedPointControl.RedPointCtrl.GetRedPointByType(RedPointControl.RedPointType.upEquip) && AIControl.default._instance.ShowClickBtn(t.auto_ui.btn_wareHouseBtn.node, function () {
          t.ShowViewByType(1);
        });
      }
      HallGlobalVariable.default.selfMap["战斗按钮"] = this.auto_ui.btn_fightingBtn.node;
    }
  };
  _creator.prototype.ifJiXuGame = function () {
    if (!(PlayerDataManager.PlayerDataMgr.GetGuideIndexByTaskName(Const_Common.GuideName.战斗背包) != Const_Common.GameBagGuideIndex.引导完结 || AIControl.default._instance.isOpen)) {
      if (GameDataManager.GameDataMgr.getJiXuGame()) {
        UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_JiXuGame, 1);
        this.ShowViewByType(2);
      }
      if (GameDataManager.GameDataMgr.getJiXuTiaoZhan()) {
        this.ShowViewByType(3);
        UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_JiXuGame, 2);
      } else if (-1 != GameGlobalVariable.GameGlobalVariable.nowlevel) {
        this.ShowViewByType(2);
      } else {
        this.ShowViewByType(3);
      }
    }
  };
  _creator.prototype.start = function () {
    var e = this;
    this.scheduleOnce(function () {
      if (PlayerDataManager.PlayerDataMgr.GetGuideIndexByTaskName(Const_Common.GuideName.仓库升级) == Const_Common.UpEquipLevelGuideIndex.引导点击仓库水果2) {
        var t = e;
        var o = t.auto_ui.btn_wareHouseBtn.node;
        var n = o.convertToWorldSpaceAR(cc.v2(0, 0));
        var i = cc.size(o.width, o.height);
        var a = (e.node.height - 1334) / 2;
        GuideControl.GuideCtrl.ShowGuide({
          callBack: function () {
            t.ShowViewByType(1);
          },
          sayStr: "获得了水果碎片，去给水果升级提升战力吧",
          wPos: n,
          size: i,
          sayNodePos: cc.v2(0, -250 - a)
        });
      }
    });
  };
  _creator.prototype._addEventListener = function () {
    this._addEvent(EvenType.EVENT_TYPE.Game_count_down_time, this._refreshTime, this);
    this._addEvent(EvenType.EVENT_TYPE.Hall_ResetRich, this.ResetRichLabel, this);
    this._addEvent(EvenType.EVENT_TYPE.Hall_StartGame, this._start, this);
    this._addEvent(EvenType.EVENT_TYPE.GAME_TIAOZHAN_VIEW, this.openTeShuTiao, this);
    this._addEvent(EvenType.EVENT_TYPE.HallResetUnLockFurit, this.CheckUnLockFurit, this);
  };
  _creator.prototype._clickListener = function (e) {
    var t = this.auto_ui;
    switch (e) {
      case t.btn_start:
        this._start();
        break;
      case t.btn_choice:
        this._choice();
        break;
      case t.btn_setting:
        this._setting();
        break;
      case this.auto_ui.btn_sidebar:
        this._sidebar();
        break;
      case this.auto_ui.btn_shopBtn:
        this.ShowViewByType(0);
        break;
      case this.auto_ui.btn_wareHouseBtn:
        this.ShowViewByType(1);
        break;
      case this.auto_ui.btn_fightingBtn:
        this.ShowViewByType(2);
        break;
      case this.auto_ui.btn_newsBtn:
        this.ShowViewByType(3);
        break;
      case this.auto_ui.btn_powerAddBtn:
        UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_AddPower);
        break;
      case this.auto_ui.btn_goldAddBtn:
        this.ShowViewByType(0, {
          isBottom: true
        });
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.HallScrollShop, {
          isBottom: true
        });
        break;
      case this.auto_ui.btn_diamondAddBtn:
        this.ShowViewByType(0, {
          isUp: true
        });
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.HallScrollShop, {
          isUp: true
        });
    }
  };
  _creator.prototype._start = function (e, t) {
    undefined === e && (e = 1);
    undefined === t && (t = false);
    if (PlayerDataManager.PlayerDataMgr.globalData.power >= GameGlobalVariable.GameGlobalVariable.kaishitilicount || t) {
      t || PlayerDataManager.PlayerDataMgr.SubPower(GameGlobalVariable.GameGlobalVariable.kaishitilicount);
      EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Load_View, true);
      this.onHideView();
      GameGlobalVariable.GameGlobalVariable.nowlevel = e;
      GameGlobalVariable.GameGlobalVariable.offtime = new Date().getTime();
      UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_GameView);
    } else {
      TipsManager.TipMgr.showToast("体力不够");
    }
  };
  _creator.prototype.openTeShuTiao = function () {
    EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Load_View, true);
    this.onHideView();
    GameGlobalVariable.GameGlobalVariable.teshulevel = 1;
    GameGlobalVariable.GameGlobalVariable.nowlevel = -1;
    this._close();
    UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_GameView);
  };
  _creator.prototype.onHideView = function () {
    ModuleManager.ModuleMgr.cleanModule();
    this._close();
  };
  _creator.prototype._choice = function () { };
  _creator.prototype._setting = function () {
    this.auto_ui.node_setting.active = !this.auto_ui.node_setting.active;
  };
  _creator.prototype._sidebar = function () {
    UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_Sidebar);
  };
  _creator.prototype.onResume = function (e) {
    var t = [];
    for (var o = 1; o < arguments.length; o++) {
      t[o - 1] = arguments[o];
    }
    AudioManager.AudioMgr.playMusic("home/sound/homebgm", true, BundleConfig.BundleNames.Home);
  };
  _creator.prototype._refreshTime = function () { };
  _creator.prototype.update = function () { };
  _creator.prototype.ResetRichLabel = function () {
    var e = this.auto_ui;
    e.txt_powerLabel.string = PlayerDataManager.PlayerDataMgr.globalData.power + "/" + PlayerDataManager.PlayerDataMgr.globalData.maxPower;
    e.txt_goldLabel.string = "" + PlayerDataManager.PlayerDataMgr.globalData.gold;
    e.txt_diamondLabel.string = "" + PlayerDataManager.PlayerDataMgr.globalData.diamond;
  };
  _creator.prototype.ShowViewByType = function (e, t) {
    undefined === t && (t = {});
    this.auto_ui.node_bottomBtnFather.children.forEach(function (t, o) {
      t.children[1].active = o == e;
      if (o == e) {
        t.width = t.children[1].width;
        t.height = t.children[1].height;
      } else {
        t.width = t.children[0].width;
        t.height = t.children[0].height;
      }
    });
    console.log('ShowViewByType = ', e);
    switch (e) {
      case 0:
        ModuleManager.ModuleMgr.show(BaseModule.ModuleNames.Shop, this.auto_ui.node_NewViewFather, t);
        break;
      case 1:
        ModuleManager.ModuleMgr.show(BaseModule.ModuleNames.WareHouse, this.auto_ui.node_NewViewFather, t);
        break;
      case 2:
        ModuleManager.ModuleMgr.show(BaseModule.ModuleNames.Fighting, this.auto_ui.node_NewViewFather, t);
        break;
      case 3:
        ModuleManager.ModuleMgr.show(BaseModule.ModuleNames.News, this.auto_ui.node_NewViewFather, t);
    }
  };
  _creator.prototype.loadGame = function () {
    ResLoader.default.loadBundle(BundleConfig.BundleNames.Game).then(function () { });
  };
  __decorate([_property(UI_Hall_UIBindings.default)], _creator.prototype, "auto_ui", undefined);
  return _ref__creator = __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_Hall;